﻿$(document).ready(function(){

		setFocusSlid('#focus_links', '#focus_img', 680, 'h');

		new Rollable('#id_yinyue_part', 680);

		new Rollable('#id_meinv_part', 680);

		new Rollable('#id_wenzi_part', 680);

		new Rollable('#id_shipin_part', 680);

		new Rollable('#id_wenzi_part_2', 680);

		new Rollable('#id_wenzi_part_a', 680);

		new Rollable('#id_wenzi_part_4', 680);

		new Rollable('#id_wenzi_part_5', 680);

		new Rollable('#id_touxiang_part', 680);

		new Rollable('#id_duanpian_part', 680);

		new Rollable('#id_youqu_part', 680);


//幻灯片左右切换
(function(){

	$('#al_expand_collapse,#archives span.al_mon').css({cursor:"s-resize"});

	$('#archives span.al_mon').each(function(){

		var num=$(this).next().children('li').size();

		var text=$(this).text();

		$(this).html(text+'<sup> [ 共 <em>'+num+'</em> 篇文章 ]</sup>');

	});

		var $al_post_list=$('#archives ul.al_post_list'),

		$al_post_list_f=$('#archives ul.al_post_list:first');

		$al_post_list.hide(1,function(){

		$al_post_list_f.show();

		});

		$('#archives span.al_mon').click(function(){

		$(this).next().slideToggle(400);

		return false;

		});

		$('#al_expand_collapse').toggle(function(){

		$al_post_list.show();

		},function(){

			$al_post_list.hide();

		});

})();

});









//幻灯

function setFocusSlid(linksId, imgId, height, dir){

	var li = $(linksId).find('li');

	var count = li.length;

	var focusIndex = 0;

	var focusInterval;

	var step = 1;

	var slidover = function(){

		var li = $(linksId).find('li');

		li.removeClass('act');

		$(li[focusIndex]).addClass('act');

		$(imgId).stop();

		if(dir=='h'){

			$(imgId).animate({scrollLeft: height * focusIndex}, 300);

		}else{

			$(imgId).animate({scrollTop: height * focusIndex}, 300);

		}

	}

	var slidout = function(){

		focusInterval = setInterval(slidInterval, 5000);

	}

	var slidInterval = function(){

		slidover();

		if(focusIndex == 0){

			step = 1;

		}

		if(focusIndex == count - 1){

			step = -1;

		}

		focusIndex+=step;

	}

	li.each(function(i){

		$(this).hover(function(){

			clearInterval(focusInterval);

			focusIndex = i;

			slidover();

		}, function(){

			slidout();

		});

	});

	focusIndex = 1;

	slidout();

}



function Rollable(id, width) {

	var btns=$(id).find('div.roll a');

	var lbtn=$(btns[0]), rbtn=$(btns[1]);

	var dots=$(id).find('div.roll span');

		var dotscount = dots.length;

	var ldot=$(dots[0]), rdot=$(dots[1]);

	var rollBox=$(id).find('div.roll_box');

	var leftRoll=function() {

		rollBox.animate({scrollLeft: 0 }, 300);

		lbtn.unbind();

		ldot.unbind();

		lbtn.removeClass('lact');

		rdot.removeClass('act');

		ldot.addClass('act');

		rbtn.addClass('ract');

		rbtn.click(rightRoll);

		rdot.click(rightRoll);

	}

	var rightRoll=function() {

		rollBox.animate({scrollLeft: width }, 300);

		rbtn.unbind();

		rdot.unbind();

		rbtn.removeClass('ract');

		ldot.removeClass('act');

		rdot.addClass('act');

		lbtn.addClass('lact');

		lbtn.click(leftRoll);

		ldot.click(leftRoll);

	}

		leftRoll();

}



